<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>
            Mobile Store
        </title>
        <LINK href="style.css" rel=stylesheet>
        <META http-equiv=Content-Type
              content="text/html; charset=utf-8">
        <style type="text/css">
            body,td,th {
                font-family: "Times New Roman", Times, serif;
            }
            a {
                font-family: "Times New Roman", Times, serif;
            }
        </style>
    </head>
    <body bottomMargin=0 leftMargin=0
          topMargin=0 rightMargin=0>
        <TABLE width="1024" border=0 cellSpacing=0
               cellPadding=0 align=center>
            <tr>
                <td colspan="5"><div align="center"><a href ="index.jsp"> <img src ="image/banner.jpg" width ="1024px" height="150" ></a></div></td>
            </tr>
            <tr>
                <td colspan="5"><%@include file="menu_ngang.jsp" %></td>
            </tr>
            <td width="150" vAlign=top bgcolor ="silver" ><div align ="center"><%@include file="menu_doc.jsp" %></div></td>
            <!---Khai báo khoảng phân cách--->
            <TD bgcolor=white width="2"></TD>
            <TD vAlign=top width="720">

                <%
                    Class.forName("com.mysql.jdbc.Driver");
                    Connection con = null;
                    Statement smt = null;
                    ResultSet rst = null;
                    int i = 0;
                    try {
                        String username = "root";
                        String password = "root";
                        String url = "jdbc:mysql://127.0.0.1:3306/laptop";
                        String provider = request.getParameter("provider");
                        System.out.println(provider);

                        con = DriverManager.getConnection(url, username, password);
                        System.out.println("Da ket noi CSDL");
                        smt = con.createStatement();
                        rst = smt.executeQuery("select * from product where provider='" + provider + "'");
                        out.print("<table width=" + "720" + " height=" + "100%" + " border=" + "0" + ">");
                        while (rst.next()) {
                            if (i % 3 == 0) {
                                out.print("<tr>");
                            }
                            out.print("<td width=" + "240" + " align=" + "center" + ">" + "<img src=" + rst.getString(5) + " width=200><br>" + rst.getString(2) + "<br><font color=red>" + rst.getString(4) + " đ</font>" + "<br><a href=" + "productdetail.jsp?ID=" + rst.getString(1) + ">Chi tiết</a></td>");
                            i++;
                            if (i % 3 == 0) {
                                out.print("</tr>");
                            }
                        }
                        out.print("</table>");
                        con.close();
                        System.out.println("Dong ket noi");
                    } catch (Exception e) {
                        System.out.println("KHONG KET NOI DUOC");
                    }
                %>

            </TD>
            <!---Khai báo khoảng phân cách--->
            <TD bgcolor=white width="2"></TD>
            <TD vAlign=top width="150">
                <%@include file="Right.jsp"%>
            </TD>
        </TR>
        <!---Khai báo khoảng phân cách--->
        <TR HEIGHT="2">
            <TD colspan=5 bgcolor=white></TD>
        </TR>
        <TR HEIGHT="50">
            <TD colspan=5 align=center>
                <%@include file="bottom.jsp"%>
            </TD>
        </TR>
    </TABLE>
</body>
</html>